import { type HttpHandler, HttpResponse, http } from "msw";

export const handlers: Array<HttpHandler> = [
  http.post("/api/addTodo", async ({ request }) => {
    const { title } = (await request.json()) as any;
    return HttpResponse.json({
      data: { todo: { id: 1, title } },
      state: 1,
    });
  }),
  http.post("/api/removeTodo", async ({ request }) => {
    const { id } = (await request.json()) as any;
    return HttpResponse.json({
      data: { id },
      state: 1,
    });
  }),

  http.get("/api/todoList", async () => {
    return HttpResponse.json({
      data: { todoList: [{ id: 1, title: "写代码" }] },
      state: 1,
    });
  }),
];
